/**
 * 获得搜索参数
 * @param params
 * @returns {Object}
 */
function getSearchParams(params) {
    var searchParams = new Object();
    if (params != undefined) {
        searchParams = params;
    }
    $('.SearchForm').each(function() {
        var param = $(this).val().trim();
        if (param == undefined)
            param = '';
        searchParams[$(this).attr('name')] = param;
    });
    return searchParams;
}
//清空搜索条件
$("#Reset").click(function() {
    $('.SearchForm').val('');
});

/**
 * 页面自加载
 */
$(function() {
    var cellwidth = ($(".box-content.table-responsive").width() - 55) / 11;
    var psval = $('#datatable_info').attr('data-size');
    if (psval == undefined || psval == "") {
        psval = 10;
    }
    /**
     * easyui 生成表格数据
     */
    $('#datatable_info').datagrid({
        singleSelect: true, //允许选择多行
        striped: true,
        idField: 'id',
        remoteSort: false,
        collapsible: true,
        fit: false,
        url: 'admin/Dashboard/getData', //数据源路径
        loadMsg: '请等待数据载入....',
        pagination: true,
        rownumbers: true,
        fitColumns: true,
        pageSize: psval,
        pageList: [psval, psval * 2, psval * 3, psval * 4, psval * 5],
        columns: [[{
            field: 'login_login',
            title: '今日登录人数',
            align: 'center',
            width: cellwidth,
            sortable: true,
            formatter: function (value) {
                return value*10;
            }
        }, {
            field: 'login_reg',
            title: '今日注册人数',
            align: 'center',
            width: cellwidth,
            sortable: true,
            formatter: function (value) {
                return value*10;
            }
        }, {
            field: 'login_all',
            title: '总用户数',
            align: 'center',
            width: cellwidth,
            sortable: true,
            formatter: function (value) {
                return value*10;
            }
        }, {
            field: 'login_jobone',
            title: '个人',
            align: 'center',
            width: cellwidth,
            sortable: true
        }, {
            field: 'login_jobtwo',
            title: '企业',
            align: 'center',
            width: cellwidth,
            sortable: true
        }, {
            field: 'login_jobthr',
            title: '找活干',
            align: 'center',
            width: cellwidth,
            sortable: true
        }, {
            field: 'login_joball',
            title: '总职位数',
            align: 'center',
            width: cellwidth,
            sortable: true
        }, {
            field: 'login_date',
            title: '统计日期',
            align: 'center',
            width: cellwidth,
            sortable: true
        }]],
        onBeforeLoad: function (param) {
            param = getSearchParams(param);
        },
    });
    /*搜索*/
    $('#Search').click(function () {
        $('#datatable_info').datagrid('reload');
    })
    
});